/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ships.core.icc;

import ships.core.icc.IccDefs.icValidateStatus;
import ships.core.icc.icProfileHeader.icCmmSignature;
import ships.core.icc.icProfileHeader.icColorSpaceSignature;
import ships.core.icc.icProfileHeader.icColorantEncoding;
import ships.core.icc.icProfileHeader.icColorimetricIntentImageStateSignature;
import ships.core.icc.icProfileHeader.icDateTimeNumber;
import ships.core.icc.icProfileHeader.icIlluminant;
import ships.core.icc.icProfileHeader.icMeasurementFlare;
import ships.core.icc.icProfileHeader.icMeasurementGeometry;
import ships.core.icc.icProfileHeader.icPlatformSignature;
import ships.core.icc.icProfileHeader.icProfileClassSignature;
import ships.core.icc.icProfileHeader.icProfileID;
import ships.core.icc.icProfileHeader.icReferenceMediumGamutSignature;
import ships.core.icc.icProfileHeader.icRenderingIntent;
import ships.core.icc.icProfileHeader.icSpotShape;
import ships.core.icc.icProfileHeader.icStandardObserver;
import ships.core.icc.icProfileHeader.icTagSignature;
import ships.core.icc.icProfileHeader.icTagTypeSignature;
import ships.core.icc.icProfileHeader.icTechnologySignature;
import ships.core.icc.icProfileHeader.icXYZNumber;

/**
 *
 * @author fqhuy
 */
public class IccUtil {

    public class CIccInfo {

        //Signature values
        public String GetVersionName(int val) {
            throw new UnsupportedOperationException();
        }

        public String GetDeviceAttrName(long val) {
            throw new UnsupportedOperationException();
        }

        public String GetProfileFlagsName(int val) {
            throw new UnsupportedOperationException();
        }

        public String GetTagSigName(icTagSignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetTechnologySigName(icTechnologySignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetTagTypeSigName(icTagTypeSignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetColorSpaceSigName(icColorSpaceSignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetProfileClassSigName(icProfileClassSignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetPlatformSigName(icPlatformSignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetCmmSigName(icCmmSignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetReferenceMediumGamutSigNameName(icReferenceMediumGamutSignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetColorimetricIntentImageStateName(icColorimetricIntentImageStateSignature sig) {
            throw new UnsupportedOperationException();
        }

        public String GetSigName(int val) {
            throw new UnsupportedOperationException();
        }

        //Other values
        public String GetMeasurementFlareName(icMeasurementFlare val) {
            throw new UnsupportedOperationException();
        }

        public String GetMeasurementGeometryName(icMeasurementGeometry val) {
            throw new UnsupportedOperationException();
        }

        public String GetRenderingIntentName(icRenderingIntent val) {
            throw new UnsupportedOperationException();
        }

        public String GetSpotShapeName(icSpotShape val) {
            throw new UnsupportedOperationException();
        }

        public String GetStandardObserverName(icStandardObserver val) {
            throw new UnsupportedOperationException();
        }

        public String GetIlluminantName(icIlluminant val) {
            throw new UnsupportedOperationException();
        }

        public String GetUnknownName(int val) {
            throw new UnsupportedOperationException();
        }

        public String GetMeasurementUnit(int sig) {
            throw new UnsupportedOperationException();
        }

        public String GetProfileID(icProfileID profileID) {
            throw new UnsupportedOperationException();
        }

        public String GetColorantEncoding(icColorantEncoding colorant) {
            throw new UnsupportedOperationException();
        }

        public boolean IsProfileIDCalculated(icProfileID profileID) {
            throw new UnsupportedOperationException();
        }

        public icValidateStatus CheckData(String sReport, icDateTimeNumber dateTime) {
            throw new UnsupportedOperationException();
        }

        public icValidateStatus CheckData(String sReport, icXYZNumber XYZ) {
            throw new UnsupportedOperationException();
        }

        public boolean IsValidSpace(icColorSpaceSignature sig) {
            throw new UnsupportedOperationException();
        }
        protected char m_szStr[] = new char[128];
        protected char m_szSigStr[] = new char[128];
    }

    public static byte[] intToByteArray(int value) {
        return new byte[]{
                    (byte) (value >>> 24),
                    (byte) (value >>> 16),
                    (byte) (value >>> 8),
                    (byte) value};
    }

    public static int[] byteArrayToIntArray(byte[] arr){
        int count = (int) Math.ceil(arr.length/4);
        int[] re = new int[count];
        byte[] temp = new byte[4];
        for (int i = 0;i< count;i++){
            temp[i*4] = arr[i];
            temp[i*4+1] = arr[i];
            temp[i*4+2] = arr[i];
            temp[i*4+3] = arr[i];
            re[i] = IccUtil.byteArrayToInt(temp);
        }

        return re;
    }

    public static int byteArrayToInt(byte[] b) {
        return (b[0] << 24)
                + ((b[1] & 0xFF) << 16)
                + ((b[2] & 0xFF) << 8)
                + (b[3] & 0xFF);
    }
/*
public static void icSwab16Ptr(void *pVoid)
{Integer.
  icUInt8Number *ptr = (icUInt8Number*)pVoid;
  icUInt8Number tmp;

  tmp = ptr[0]; ptr[0] = ptr[1]; ptr[1] = tmp;
}

inline void icSwab16Array(void *pVoid, int num)
{
  icUInt8Number *ptr = (icUInt8Number*)pVoid;
  icUInt8Number tmp;

  while (num>0) {
    tmp = ptr[0]; ptr[0] = ptr[1]; ptr[1] = tmp;
    ptr += 2;
    num--;
  }
}

inline void icSwab32Ptr(void *pVoid)
{
  icUInt8Number *ptr = (icUInt8Number*)pVoid;
  icUInt8Number tmp;

  tmp = ptr[0]; ptr[0] = ptr[3]; ptr[3] = tmp;
  tmp = ptr[1]; ptr[1] = ptr[2]; ptr[2] = tmp;
}

inline void icSwab32Array(void *pVoid, int num)
{
  icUInt8Number *ptr = (icUInt8Number*)pVoid;
  icUInt8Number tmp;

  while (num>0) {
    tmp = ptr[0]; ptr[0] = ptr[3]; ptr[3] = tmp;
    tmp = ptr[1]; ptr[1] = ptr[2]; ptr[2] = tmp;
    ptr += 4;
    num--;
  }

}

inline void icSwab64Ptr(void *pVoid)
{
  icUInt8Number *ptr = (icUInt8Number*)pVoid;
  icUInt8Number tmp;

  tmp = ptr[0]; ptr[0] = ptr[7]; ptr[7] = tmp;
  tmp = ptr[1]; ptr[1] = ptr[6]; ptr[6] = tmp;
  tmp = ptr[2]; ptr[2] = ptr[5]; ptr[5] = tmp;
  tmp = ptr[3]; ptr[3] = ptr[4]; ptr[4] = tmp;
}

inline void icSwab64Array(void *pVoid, int num)
{
  icUInt8Number *ptr = (icUInt8Number*)pVoid;
  icUInt8Number tmp;

  while (num>0) {
    tmp = ptr[0]; ptr[0] = ptr[7]; ptr[7] = tmp;
    tmp = ptr[1]; ptr[1] = ptr[6]; ptr[6] = tmp;
    tmp = ptr[2]; ptr[2] = ptr[5]; ptr[5] = tmp;
    tmp = ptr[3]; ptr[3] = ptr[4]; ptr[4] = tmp;
    ptr += 8;
    num--;
  }

}
 * 
 */
}
